const express = require('express');

const app = express();// express.static 提供静态文件，就是html, css, js 文件
app.use(express.static('public'));

// 电话号码返回省和市，为了模拟延迟，使用了setTimeout
app.post('/phoneLocation', (req, res) => {
    setTimeout(() => {
        res.json({
            success: true,
            obj: {
                province: '广东',
                city: '深圳',
            },
            phoneNum:req.query.phoneNum
        })
    }, 1000);
})

// 返回面值列表
app.post('/faceList', (req, res) => {
    setTimeout(() => {
        res.json(
            {
                success: true,
                obj:['20元', '30元', '50元','100元'],
                province:req.query.province,
                city:req.query.city
            }
        )
    }, 1000);
})

app.listen(9501, () => {
    console.log('server start at http://localhost:9501');
})